package com.imay.live.adapter.normal;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
* Title: CommonBaseAdapter.java <br/>
* Description:通用的adapter <br/>
*/
public abstract class CommonBaseAdapter<T> extends BaseAdapter {

	protected List<T> data;
	protected Context context;
	protected LayoutInflater inflater;
	
	public CommonBaseAdapter(final List<T> data, final Context context ){
		this.data  = data;
		this.context = context;
		inflater = LayoutInflater.from(context);
	}
	
	@Override
	public int getCount() {
		return data  == null ? 0: data.size();
	}
	
	@Override
	public Object getItem(int position) {
		return data  == null ? null: data.get(position);
	}
	
	@Override
	public long getItemId(int position) {
		return position;
	}
	
	
	@Override
	public abstract View getView(int position, View convertView, ViewGroup parent);

	public void setData(List<T> data) {
		this.data = data;
	}

	public List<T> getData() {
		return data;
	}
}
